function longestCommonPrefix(strs) {
  let end = 0
  while(strs.every(item => (end < item.length) && (strs[0][end] === item[end]))){
    end ++
  }
  return strs[0].slice(0, end) || ""
}

console.log(longestCommonPrefix(["a"]))
